/*
 * @Author: your name
 * @Date: 2021-05-24 10:16:24
 * @LastEditTime: 2021-05-24 15:01:58
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \5.24\dan\src\router\index.js
 */
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: () => import('../views/Home'),
    redirect: '/First',
    children: [
      {
        path: '/First',
        component: () => import('../views/First'),
        redirect: '/One',
        children: [
          {
            path: '/One',
            component: () => import('../views/Homes/One')
          },
          {
            path: '/Two',
            component: () => import('../views/Homes/Two')
          },
          {
            path: '/Three',
            component: () => import('../views/Homes/Three')
          },
          {
            path: '/Four',
            component: () => import('../views/Homes/Four')
          },
          {
            path: '/Five',
            component: () => import('../views/Homes/Five'),
            beforeEnter: (to, from, next) => {
              const token = window.localStorage.getItem('token')
              if (token) {
                next()
              } else {
                next('/Login')
              }
            }
          }
        ]
      },
      {
        path: '/Shop',
        component: () => import('../views/Shop')
      },
      {
        path: '/Order',
        component: () => import('../views/Order')
      },
      {
        path: '/Repertory',
        component: () => import('../views/Repertory')
      },
      {
        path: '/User',
        component: () => import('../views/User')
      },
      {
        path: '/Promotion',
        component: () => import('../views/Promotion')
      },
      {
        path: '/Operation',
        component: () => import('../views/Operation')
      },
      {
        path: '/Content',
        component: () => import('../views/Content')
      },
      {
        path: '/Statistics',
        component: () => import('../views/Statistics')
      },
      {
        path: '/Finance',
        component: () => import('../views/Finance')
      },
      {
        path: '/Set',
        component: () => import('../views/Set')
      },
      {
        path: '/Jurisdiction',
        component: () => import('../views/Jurisdiction')
      },
      {
        path: '/My',
        component: () => import('../views/My'),
        beforeEnter: (to, from, next) => {
          const token = window.localStorage.getItem('token')
          if (token) {
            next()
          } else {
            next('/Login')
          }
        }
      }
    ]
  },
  {
    path: '/Detail',
    component: () => import('../views/Detail')
  },
  {
    path: '/Login',
    component: () => import('../views/Login')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
